package maze.net.server;

import java.io.IOException;
import java.net.Socket;

import maze.net.MessageType;
import maze.net.SGMPOutputStream;
import maze.pojo.Action;

public class SGMPServerOutputStream extends SGMPOutputStream {

	public SGMPServerOutputStream(Socket socket) throws IOException {
		super(socket.getOutputStream());
	}

	public void sendPlayerReady(int playerId) throws IOException {
		send(MessageType.S_PlayerReady, (byte) playerId);
	}

	public void sendCountdown(long seed) throws IOException {
		send(MessageType.S_Countdown, seed);
	}

	public void sendAction(Action act1, Action act2) throws IOException {
		send(MessageType.S_Action, (byte)((act1.bit << 4) | act2.bit));
	}
	
	public void sendWin(Action act1, Action act2) throws IOException {
		send(MessageType.S_Win, (byte)((act1.bit << 4) | act2.bit));
	}
	
	public void sendLose(Action act1, Action act2) throws IOException {
		send(MessageType.S_Lose, (byte)((act1.bit << 4) | act2.bit));
	}
	
	public void sendDraw(Action act1, Action act2) throws IOException {
		send(MessageType.S_Draw, (byte)((act1.bit << 4) | act2.bit));
	}
}
